package com.zucc.controller;

import com.zucc.controller.req.TeachRoomAddReq;
import com.zucc.controller.req.TeachRoomModifyReq;
import com.zucc.controller.req.TeachRoomSearchReq;
import com.zucc.controller.resp.TeachRoomResp;
import com.zucc.service.TeachRoomService;
import com.zucc.service.base.PageData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : charspan
 * @Description :
 * @create : 2022-04-07 5:49 下午
 */
@RestController
@Slf4j
@RequestMapping("/v1/api/teachRooms")
@Api(tags = "教室使用信息管理")
public class TeachRoomController {

    @Resource
    private TeachRoomService teachRoomService;

    @ApiOperation(value = "新增教室使用信息")
    @PostMapping
    void add(@RequestBody @Validated TeachRoomAddReq req) {
        teachRoomService.add(req);
    }

    @ApiOperation(value = "修改教室使用信息")
    @PutMapping
    void modify(@RequestBody @Validated TeachRoomModifyReq req) {
        teachRoomService.modify(req);
    }

    @ApiOperation(value = "删除教室使用信息")
    @ApiImplicitParam(paramType = "path", name = "id", value = "教室使用信息编号", dataType = "Long", example = "1", required = true)
    @DeleteMapping("/{id}")
    void deleteOne(@PathVariable Long id) {
        teachRoomService.deleteOne(id);
    }

    @ApiOperation(value = "教室使用信息分页")
    @PostMapping("/page")
    PageData<TeachRoomResp> page(@RequestBody @Validated TeachRoomSearchReq req) {
        return teachRoomService.page(req);
    }
}
